package com.oocl.operation.impl;

import java.util.Map;

import com.oocl.db.Storager;
import com.oocl.operation.UserThreadOperation;
import com.oocl.server.UserThread;

public class UserTheadOpetationImpl implements UserThreadOperation{
	private Map<String, UserThread> currUserThreads;
	
	public UserTheadOpetationImpl() {
		this.currUserThreads = Storager.accessUserThreads();
	}

	@Override
	public UserThread findByName(String name) {
		for(String s:currUserThreads.keySet()){
			if(s.equals(name)){
				return this.currUserThreads.get(s);
			}
		}
		return null;
	}

	@Override
	public void add(String name,UserThread userThread) {
		this.currUserThreads.put(name, userThread);
	}

	@Override
	public void removeByName(String name) {
		if(null ==name){
			return;
		}
		this.currUserThreads.remove(name);
	}

	@Override
	public Map<String, UserThread> findAll() {
		return this.currUserThreads;
	}

}
